package model;

import java.util.Vector;


/**
 * Team EBE
 * 
 * DiagramImpl.java represents a UML diagram, and maintains a list of classes 
 * and list of relationships between classes
 *
 */
public class DiagramImpl {
	private int sizeX, sizeY, numClasses;
	
	Vector<ClassImpl> classes;
	Vector<RelationshipImpl> relationships;
	Vector<PackageImpl> packages;
	
	public int getSizeX() {
		return sizeX;
	}

	public void setSizeX(int sizeX) {
		this.sizeX = sizeX;
	}

	public int getSizeY() {
		return sizeY;
	}

	public void setSizeY(int sizeY) {
		this.sizeY = sizeY;
	}
	
	public DiagramImpl(){
		sizeX = 1024;
		sizeY = 768;
		classes = new Vector<ClassImpl>();
		relationships = new Vector<RelationshipImpl>();		
		packages = new Vector<PackageImpl>();
	}
	
	public ClassImpl getClassImpl(int i){
		return classes.get(i);
	}
	public RelationshipImpl getRelationshipImpl(int i){
		return relationships.get(i);
	}
	public PackageImpl getPackageImpl(int i){
		return packages.get(i);
	}
	
	
	
	
	public void addClass (String nameIn){
		ClassImpl classIn = new ClassImpl(nameIn);
		classes.add(classIn);
		++ numClasses;
	}
	
	public void addClass (int ox, int oy){
		classes.add(new ClassImpl (ox, oy));
		System.out.println("abeokd");
		++numClasses;
	}
	
	public void addClass(ClassImpl toAdd){
		classes.add(toAdd);
		++numClasses;
	}
	public void addPackage (int ox, int oy){
		packages.add(new PackageImpl (ox, oy));
	}
	
	public void addPackage(PackageImpl toAdd){
		packages.add(toAdd);
	}
	
	public void addRelationship(AnchorPoint src, AnchorPoint dest){
		RelationshipImpl relIn = new RelationshipImpl(src, dest);
		relationships.add(relIn);
	}
	
	public void deleteClass(ClassImpl toDelete){
		classes.remove(toDelete);
	}
	
	public void deleteRelationship(RelationshipImpl toDelete){
		relationships.remove(toDelete);
	}
	
	public String saveString(){
		//int i = 1;
		String s = new String();
		//Classes then Relationships
		//s = this.numClasses + " " + this.classes + " " + this.relationships + " ";
		s = "<diagram>\n";
		//s = classes.size() + " " + relationships.size() + "\n";
		for(ClassImpl theclass : classes){
			
			s += theclass.saveString();
			
		}

		for(RelationshipImpl therelationship : relationships){
			
			
			s += therelationship.saveString();
			
		}
		return s;
	}

	public void addRelationship(RelationshipImpl toAdd) {
		relationships.add(toAdd);
		
	}

}
